# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-uutf
_pkgname=uutf
pkgver=1.0.1
pkgrel=2
pkgdesc="Non-blocking streaming Unicode codec for OCaml"
url="https://github.com/dbuenzli/uutf"
arch="all !x86 !armhf !armv7 !s390x !mips !mips64"  # limited by ocaml aport
license="ISC"
depends="ocaml-uchar"
depends_dev="$pkgname=$pkgver-r$pkgrel"
makedepends="
	ocaml
	ocaml-compiler-libs
	ocaml-cmdliner-dev
	ocaml-findlib
	ocaml-result-dev
	ocaml-topkg-dev
	ocaml-uchar-dev
	ocamlbuild
	opam
	"
options="!check"  # FXIME: needs ocaml-topkg-care
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/dbuenzli/$_pkgname/archive/v$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	cd "$builddir"
	ocaml pkg/pkg.ml build
}

package() {
	cd "$builddir"

	opam-installer -i \
		--prefix="$pkgdir/usr" \
		--libdir="$pkgdir/usr/lib/ocaml" \
		--docdir="$builddir/.omit" \
		$_pkgname.install

	# Remove annotation files.
	rm -Rf "$pkgdir"/usr/lib/ocaml/$_pkgname/*.cmt*
}

dev() {
	local sitelib="usr/lib/ocaml/$_pkgname"
	default_dev

	cd "$pkgdir"/$sitelib

	mkdir -p "$subpkgdir"/$sitelib
	mv *.cmx *.cmxa *.mli "$subpkgdir"/$sitelib/
}

sha512sums="803ea3306f977bbe937233b02b86f5dbd80b031e32b627be038b5caa60ed84df26efb896910025d7cc0addbff9a3d33b0ccce76fe3ebc5aaabf34f99c2637937  ocaml-uutf-1.0.1.tar.gz"
